package com.cqs.leetcode.tree;

import com.cqs.leetcode.TreeNode;

/**
 * @author lixqw
 * @date 2020/8/18
 */
public class BiNodeLCCI {
    public TreeNode convertBiNode(TreeNode root) {
        //中根遍历
        if (root == null) return null;
        TreeNode node = convertBiNode(root.left);
        if (node != null) {
            node.right = new TreeNode(root.val);
        } else {
            node = new TreeNode(root.val);
        }
        if (node.right == null) {
            node.right = convertBiNode(root.right);
        }else {
            node.right.right = convertBiNode(root.right);
        }
        return node;
    }

}
